#pragma once

#include "EntityDataStore.h"

namespace ZeEngine
{
	class Entity;
	class IComponent;

	class EntityManager
	{
		friend class GameEngine;

	public:
		EntityManager(GameEngine& gameEngine);
		~EntityManager();

		Entity* CreateAndAddEntity(const std::string& name, const std::string& group = "default");
		void RemoveEntity(Entity* pEntity, const std::string& group = "default");
		void Clear();

		EntityDataStore& GetEntityDataStore(const std::string& group = "default");
        std::vector<Entity*> GetAllEntities() { return m_allEntities; }

	private:
		void PreUpdate();
		void PostUpdate();

	private:
		std::map<std::string, EntityDataStore>			                m_entityDataStore;
		std::map<std::string, std::vector<Entity*>>						m_removeEntities;
		std::map<std::string, std::vector<Entity*>>						m_addEntities;
        std::vector<Entity*>                                            m_allEntities;

        GameEngine&                                                     m_gameEngine;
	};
}